//
//  CSPurchasingViewController.m
//  ChinaShip
//
//  Created by Yale on 2019/2/22.
//  Copyright © 2019年 ChinaShip. All rights reserved.
//

#import "CSPurchasingViewController.h"

@interface CSPurchasingViewController ()<UITextViewDelegate>{
    IBOutlet UITextField *nameTextField,*contactTextField;
    IBOutlet UITextView  *intentionTextView;
    IBOutlet UILabel     *placeHolderLabel;
}

@end

@implementation CSPurchasingViewController

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self showNavBar];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self addBackNavbarItem];
    self.navigationItem.title = @"Purchasing intention";
    intentionTextView.layer.cornerRadius = 5.0f;
    intentionTextView.layer.borderWidth = 1.0f;
    intentionTextView.layer.borderColor = UIRGBColor(224, 223, 224).CGColor;
}

#pragma mark - TextViewDelegate
- (void)textViewDidChange:(UITextView *)textView{
    if (textView.text.length == 0) {
        placeHolderLabel.hidden = NO;
    }else{
        placeHolderLabel.hidden = YES;
    }
}

- (IBAction)submitAccountAction:(id)sender{
    if (nameTextField.text.length == 0) {
        [SVProgressHUD showErrorWithStatus:@"The name cannot be empty"];
        return;
    }
    if (contactTextField.text.length == 0) {
        [SVProgressHUD showErrorWithStatus:@"The telephone number or E-mail cannot be empty"];
        return;
    }
    if (intentionTextView.text.length == 0) {
        [SVProgressHUD showErrorWithStatus:@"The Purchasing Intention cannot be empty"];
        return;
    }
    [SVProgressHUD show];
    
    [self performSelector:@selector(exitPush) withObject:nil afterDelay:1];
    
}

- (void)exitPush{
      [SVProgressHUD showSuccessWithStatus:@"Have received your purchase intention, we will contact you within 3 working days"];
    [self popViewController];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
